package com.liuzu.esys.controller;


import com.liuzu.esys.common.LayuiPageVo;
import com.liuzu.esys.common.R;
import com.liuzu.esys.pojo.Operate;
import com.liuzu.esys.service.OperateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Map;

@RestController
@RequestMapping("/operate")
public class OperateController {

    @Autowired
    private OperateService operateService;

    @RequestMapping("/operateList")
    public LayuiPageVo<Operate> operatePageData(@RequestParam Map<String,Object> params){
        return operateService.operatePageData(params);
    }

    @RequestMapping("/addOperate")
    public R addOperate(Operate operate){
        int result = operateService.addOperate(operate);
        if (result == 1){
            return R.ok();
        }else {
            return R.error();
        }
    }

    @RequestMapping("/updateOperate")
    public R updateOperate(Operate operate){
        int result = operateService.updateOperate(operate);
        if (result == 1){
            return R.ok();
        }else {
            return R.error();
        }
    }

    @GetMapping("/deleteOperate")
    public R deleteOperate(Integer id){
        int result = operateService.deleteOperate(id);
        if (result == 1){
            return R.ok();
        }else {
            return R.error();
        }
    }

    @GetMapping("/deleteOperates")
    public R deleteOperates(String ids){
        int result = operateService.deleteOperateByIds(ids);
        if (result == 1){
            return R.ok();
        }else {
            return R.error();
        }
    }

}
